﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using AdvancedStandingAndScholarship.ASASService;
using System.Windows.Browser;
using System.ServiceModel;

namespace AdvancedStandingAndScholarship.Views
{
    public partial class ForgetPasswordPage : Page
    {
        public ForgetPasswordPage()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void btnBack_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            // TODO: Add event handler implementation here.
            NavigationService.GoBack();
        }

        private void Submit_click(object sender, RoutedEventArgs e)
        {
            string fromEmail = "asasEmailFunction@gmail.com"; //pw:asasenjoyit
            string toEmail = tbxEmail.Text;
            string subject = "ASAS Password Recovery";
            string body = "Dear user, this is your password.";


            ASASService.ASASServiceClient client = new ASASService.ASASServiceClient();

            client.SendEmailAsync(fromEmail, toEmail, subject, body);
            client.SendEmailCompleted += new EventHandler<SendEmailCompletedEventArgs>(client_SendEmailCompleted);


        }

        void client_SendEmailCompleted(object sender, SendEmailCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                if (e.Result)
                {
                    MessageBox.Show("Email send successfully.");
                }
                else
                {
                    MessageBox.Show("Unable to send email.");
                }
            }
        }

    }
}
